#-----------------------------------------------------------------------------
#
# ParaViewConfig.cmake - ParaView CMake configuration file for external projects.
#
# This file is configured by ParaView and used by the UseParaView.cmake module
# to load ParaView's settings for an external project.
set (__pv_install_tree @PARAVIEW_CONFIG_INSTALLED@)
if (__pv_install_tree)
  get_filename_component(location "${CMAKE_CURRENT_LIST_FILE}" PATH)
  set (VTK_CONFIG_FILE "${location}/VTKConfig.cmake")
  set (ParaView_CMAKE_DIR "${location}")
  set (PARAVIEW_CONFIG_TARGETS_FILE "${location}/ParaViewTargets.cmake")
else()
  # The ParaView is in the build-location.
  set (VTK_CONFIG_FILE "@ParaView_BINARY_DIR@/VTK/VTKConfig.cmake")
  set (ParaView_CMAKE_DIR "@ParaView_CMAKE_DIR@")
  set (PARAVIEW_CONFIG_TARGETS_FILE "@ParaView_BINARY_DIR@/ParaViewTargets.cmake")
endif()

#------------------------------------------------------------------------------
# Version information for ParaView
SET(PARAVIEW_VERSION_MAJOR "@PARAVIEW_VERSION_MAJOR@")
SET(PARAVIEW_VERSION_MINOR "@PARAVIEW_VERSION_MINOR@")
SET(PARAVIEW_VERSION_PATCH "@PARAVIEW_VERSION_PATCH@")
SET(PARAVIEW_VERSION_FULL  "@PARAVIEW_VERSION_FULL@")
SET(PARAVIEW_VERSION       "@PARAVIEW_VERSION@")

# The location of the UseParaView.cmake file
# FIXME: I don't like this mixing of case, we need to fix that to be consistent.
set (ParaView_USE_FILE "${ParaView_CMAKE_DIR}/UseParaView.cmake")

set (PARAVIEW_USE_FILE ${ParaView_USE_FILE})
set (PARAVIEW_CMAKE_DIR ${ParaView_CMAKE_DIR})

# Setup VTK-m if it was enabled
set(PARAVIEW_USE_VTKM @PARAVIEW_USE_VTKM@)
if(PARAVIEW_USE_VTKM)
   set(VTKM_CMAKE_DIR "${VTK_CMAKE_DIR}")
  if(NOT __vtk_install_tree)
    set(VTKM_CMAKE_DIR "@VTKm_BINARY_DIR@/@VTK_INSTALL_PACKAGE_DIR@/vtkm")
  endif()
  get_filename_component(VTKM_CMAKE_DIR "${VTKM_CMAKE_DIR}" PATH)
  find_package(VTKm
               PATHS "${CMAKE_CURRENT_LIST_DIR}"
                     "${VTKM_CMAKE_DIR}"
                     "${VTK_RUNTIME_DIRS}"
               NO_DEFAULT_PATH
               )
endif()

# Import ParaView targets.
if(NOT TARGET vtkPVCommon)
  include("${PARAVIEW_CONFIG_TARGETS_FILE}")
endif()

# load VTK config. This will bring in information about all modules (including
# ParaView's modules).
set (paraview_build_qt_gui "@PARAVIEW_BUILD_QT_GUI@")
if (paraview_build_qt_gui)
  set (VTK_FIND_COMPONENTS pqApplicationComponents)
else()
  set (VTK_FIND_COMPONENTS vtkPVServerManagerApplication)
endif()

set (PARAVIEW_QT_VERSION "@PARAVIEW_QT_VERSION@")
set (VTK_FIND_COMPONENTS ${VTK_FIND_COMPONENTS} ${ParaView_FIND_COMPONENTS})
include("${VTK_CONFIG_FILE}")

if (__pv_install_tree)
  if (WIN32)
    set (PARAVIEW_RUNTIME_DIRS "${VTK_INSTALL_PREFIX}/@VTK_INSTALL_RUNTIME_DIR@")
  else ()
    set (PARAVIEW_RUNTIME_DIRS "${VTK_INSTALL_PREFIX}/@VTK_INSTALL_LIBRARY_DIR@")
  endif ()
  set (PARAVIEW_WWW_DIR "${VTK_INSTALL_PREFIX}/www")
else()
  if (WIN32)
    set (PARAVIEW_RUNTIME_DIRS "@ParaView_BINARY_DIR@/bin")
  else ()
    set (PARAVIEW_RUNTIME_DIRS "@ParaView_BINARY_DIR@/lib")
  endif ()
  list(APPEND VTK_INCLUDE_DIRS "@ParaView_BINARY_DIR@")
  set (PARAVIEW_WWW_DIR "@ParaView_BINARY_DIR@/www")
endif()

# unless using external vtk (when we start supporting it, that is)
# PARAVIEW_INCLUDE_DIRS is same as VTK_INCLUDE_DIRS, but to make it easier for
# ParaView users.
set (PARAVIEW_INCLUDE_DIRS ${VTK_INCLUDE_DIRS})

#------------------------------------------------------------------------------
# ParaView global configuration options.

set (PARAVIEW_BUILD_SHARED_LIBS "@BUILD_SHARED_LIBS@")
set (PARAVIEW_BUILD_QT_GUI "@PARAVIEW_BUILD_QT_GUI@")
set (PARAVIEW_ENABLE_EMBEDDED_DOCUMENTATION "@PARAVIEW_ENABLE_EMBEDDED_DOCUMENTATION@")
set (PARAVIEW_USE_MPI "@PARAVIEW_USE_MPI@")
set (PARAVIEW_ENABLE_PYTHON "@PARAVIEW_ENABLE_PYTHON@")
set (PARAVIEW_ENABLE_QT_SUPPORT "@PARAVIEW_ENABLE_QT_SUPPORT@")
set (PARAVIEW_USE_VISITBRIDGE "@PARAVIEW_USE_VISITBRIDGE@")
set (PARAVIEW_ENABLE_COPROCESSING "@PARAVIEW_ENABLE_COPROCESSING@")
set (PARAVIEW_ENABLE_WEB "@PARAVIEW_ENABLE_WEB@")

if (NOT @VTK_LEGACY_REMOVE@)
  if (PARAVIEW_ENABLE_PYTHON)
    if (__pv_install_tree)
      set(PARAVIEW_PYTHONPATH "${VTK_INSTALL_PREFIX}/@VTK_INSTALL_PYTHON_MODULES_DIR@")
    else ()
      set(PARAVIEW_PYTHONPATH "@VTK_BUILD_PYTHON_MODULES_DIR@")
    endif ()
  endif ()
endif ()

if(PARAVIEW_ENABLE_QT_SUPPORT)
  # If Qt support is enabled, provides clues to Qt version used to build ParaView.
  if(PARAVIEW_QT_VERSION VERSION_GREATER "4")
    # nothing to do. the module system handles it properly.
  else()
    set(PARAVIEW_QT_QMAKE_EXECUTABLE "@QT_QMAKE_EXECUTABLE@")
  endif()
endif()

# cleanup
unset(__pv_install_tree)
